package org.colcon.web.client.ui;

import org.colcon.web.client.ColConServiceAsync;
import org.colcon.web.client.Collective_Congress;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;

public abstract class ColConPanel extends HTMLPanel 
{
	private Collective_Congress client;
	
	public ColConPanel(Collective_Congress client)
	{
		this(client, null, null);
	}
	
	public ColConPanel(Collective_Congress client, String style)
	{
		this(client, style, null);
	}
	
	public ColConPanel(Collective_Congress client, String style, String text)
	{
		super(text);
		
		this.client = client;

		if(style != null && style.length() > 0)
			addStyleName(style);
	}
	
	public Collective_Congress getClient()
	{
		return client;
	}
	
	public ColConServiceAsync getService()
	{
		return getClient().getService();
	}
	
	public MainPanel getMainPanel()
	{
		return getClient().getMainPanel();
	}
	
	public HeaderPanel getHeaderPanel()
	{
		return getClient().getHeaderPanel();
	}
	
	public BodyPanel getBodyPanel()
	{
		return getClient().getBodyPanel();
	}
	
	public void setFocus(final Widget widget)
	{
		Scheduler.get().scheduleDeferred(new ScheduledCommand() {
	        public void execute () 
	        {
	        	widget.getElement().focus();
	        }
		});
	}
}
